<?php
class Menu extends Produit{
	public $nbPizzas;
	public $nbBoissons;
	public $pizzasID=array();
	public $boissonsID=array();
	
	public function __construct($id, $nom, $prix,$nbBoissons,$nbPizzas)
	{
		parent::__construct($id, $nom, $prix);
		$this->nbPizzas=$nbPizzas;
		$this->nbBoissons=$nbBoissons;
	}
	public function ajouterPizza($idPizza){
		if(count($pizzasID)<$this->nbPizzas){
			$this->pizzasID[]=$idPizza;
		}
	}
	public function ajouterBoisson($idBoisson){
		if(count($boissonsID)<$this->nbBoissons){
			$this->boissonsID[]=$idBoisson;
		}
	}
	public function  getXML(){
		$xml = new DOMDocument;
		$xml->formatOutput = true;
	
		$menu = $xml->createElement('menu');
		$menuNode=$xml->appendChild($menu);
		$menuNode->setAttribute('id',$this->id);
		$menuNode->appendChild(new DOMElement('nom',$this->nom));
		$menuNode->appendChild(new DOMElement('prix',$this->prix));
		$menuNode->appendChild(new DOMElement('nbPizzas',$this->nbPizzas));
		$menuNode->appendChild(new DOMElement('nbBoissons',$this->nbBoissons));
		return $xml->getElementsByTagName('menu')->item(0);
	}
}